<?php
class Cms
{
	public static function factory($action, $table, $schema = null,
		$database = null)
	{
		// Default adapter
		$db = Zend_Db_Table::getDefaultAdapter();
		
		switch(get_class($db)) {
			case 'Zend_Db_Adapter_Pdo_Mysql':
				
				$crud = "Cms_{$action}_Mysql";
				
				break;
			case 'Zend_Db_Adapter_Pdo_Pgsql':
				
				$crud = "Cms_{$action}_Pgsql";
				
				break;
			default:
				throw new Zend_Exception('Nenhum adaptador encontrado');
		}
		
		$cms = "Cms_$action";
		$cms = new $cms();
		
		return $cms->setCms(
			new $crud(),
			array(
				'table' => $table,
				'schema' => $schema,
				'database' => $database
			)
		);
	}
}